package com.owg.jigsaw;

import java.util.Queue;

import com.owg.jigsaw.hierarchy.TypeNode;
import com.owg.jigsaw.slots.Slot;

import javafx.geometry.Point2D;
import javafx.scene.Node;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import owg.util.data.PFieldElement;
import owg.util.data.property.Property;

public interface WNode extends PFieldElement
{
	// Basically, there are some tasks that we need to do before doing 
	// anything with the tree and this is the best place to do it.
	// Unfortunately, it is not possible to have static blocks in an
	// interface, but it is possible to have inner classes and constants.
	@Deprecated
	final I i = I.I; 
	@Deprecated
	enum I
	{
		@Deprecated
		I;
		static 
		{
			Property.registerImmutableClass(Node.class);
			Property.registerImmutableClass(TypeNode.class);
			Property.registerImmutableClass(Color.class);
			Property.registerImmutableClass(WNode.class);
		}
	}
	
	public WContainer<?> getParent();
	public WRoot getRoot();
	public Pane getUI();
	/**Enqueue all slots that are potential drop targets in this subtree*/
	public void putTargetSlots(Queue<Slot> sq);
	/**Returns the block at the indicated position in local space. 
	 * If the position is out of bounds, then this will return null.*/
	public WBlock getBlockAt(Point2D localPoint);
	/**Get the nearest WPane upstream in the hierarchy, null if none.*/
	public default WPane getWPane()
	{
		if(this instanceof WPane)
			return (WPane) this;
		WContainer<?> p = getParent();
		if(p == null)
			return null;
		return p.getWPane();
	}
}
